
'''
类的设计
class 标识符():

    属性
    方法

'''

from random import random


class Zombie:

    def __str__(self):
        return f"name是{self.name},血量是{self.hp}"

    def __init__(self,hp,name):

        #z1.aggressivity = 10
        self.name = name
        self.hp = hp
        print('僵尸被创建了')

    def __del__(self):
        print("对象被销毁了")
    def beaten_up(self,attc):
        self.hp-=attc


z1 = Zombie(100,'普通僵尸')#追加了两句 z1.name = 'aaaa'  z1.aggressivity = 10
z2 = Zombie(200,'路障僵尸')

z2 = z1

z1.beaten_up(10)

print(z1.hp)
print(z2.hp)


#内置的方式,用来输出实例的属性的
print(Zombie.__dict__)

print(z1.__dict__)

print(z1)


# map1 = {}
#
# map1['hp'] = 10
#
# print(map1)